package cn.edu.flink.scala.tutorial.source

import org.apache.flink.api.common.RuntimeExecutionMode
import org.apache.flink.streaming.api.scala._


object ReadFileTest {
  def main(args: Array[String]): Unit = {
    val env = StreamExecutionEnvironment.createLocalEnvironmentWithWebUI()
    env.setParallelism(1)
    // 使用批处理模式
    env.setRuntimeMode(RuntimeExecutionMode.BATCH)

    val text: DataStream[String] = env.readTextFile("input/event.txt")
    val eventsDS = text
      .map(_.split(" "))
      .map(line => Event(line(0), line(1), line(2).toLong))

    eventsDS.print()

    env.execute("ReadFile")
  }
}
